using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using UwinEducation.Shared.Enums;

namespace UwinEducation.Domain.Entities
{
    /// <summary>
    /// 学生课表实体
    /// </summary>
    [Table("student_schedules")]
    public class StudentSchedule : EntityBase
    {
        /// <summary>
        /// 学生课表ID
        /// </summary>
        public Guid Id { get; set; }

        /// <summary>
        /// 学生ID
        /// </summary>
        public Guid StudentId { get; set; }

        /// <summary>
        /// 教师课表详情ID
        /// </summary>
        public Guid TeacherScheduleDetailsId { get; set; }

        /// <summary>
        /// 教师课表ID
        /// </summary>
        public Guid TeacherScheduleId { get; set; }

        /// <summary>
        /// 课表状态
        /// </summary>
        public ScheduleStatus Status { get; set; }

        /// <summary>
        /// 废弃原因
        /// </summary>
        public string? Reason { get; set; }

        /// <summary>
        /// 是否强校验
        /// </summary>
        public bool IsForceCheck { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remarks { get; set; }


        /// <summary>
        /// 学生信息
        /// </summary>
        public virtual Student Student { get; set; }
        /// <summary>
        /// 教师课表信息
        /// </summary>
        public virtual TeacherSchedule TeacherSchedule { get; set; }

        public virtual TeacherScheduleDetails TeacherScheduleDetails { get; set; }


        /// <summary>
        /// 创建学生课表记录
        /// </summary>
        public static StudentSchedule Create(
            Guid studentId,
            Guid teacherScheduleId,
            Guid teacherScheduleGroupId,
            bool isForceCheck,
            string? reason,
            string? remarks = null)
        {
            return new StudentSchedule
            {
                Id = Guid.NewGuid(),
                StudentId = studentId,
                TeacherScheduleDetailsId = teacherScheduleId,
                TeacherScheduleId = teacherScheduleGroupId,
                Status = ScheduleStatus.Normal,
                IsForceCheck = isForceCheck,
                Reason = reason,
                Remarks = remarks,
                CreatedAt = DateTime.Now
            };
        }
    }
}